# -*- mode: python -*-
Import("env")
Import("debugBuild")
Import("use_libunwind")

env = env.Clone()

# Do not link with DLL version of the CRT.
# As part of install, we may need to install the CRT DLL but if it is not installed, we cannot run
# the installer if we dynamically linked against it.
#
bad_flags = [a for a in env["CCFLAGS"] if a.startswith("/M")]

for flag in bad_flags:
    env["CCFLAGS"].remove(flag)

if debugBuild:
    env["CCFLAGS"].append("/MTd")
else:
    env["CCFLAGS"].append("/MT")

env.Append(
    LIBS=[
        "msi",
        "user32",
    ]
)

ca = env.SharedLibrary(
    target="mongoca",
    source=[
        "customaction.cpp",
        "customaction.def",
    ],
    # We don't want any special allocator here either.
    LIBDEPS_NO_INHERIT=[
        "$BUILD_DIR/third_party/gperftools/tcmalloc_minimal",
        "$BUILD_DIR/third_party/tcmalloc/tcmalloc",
        "$BUILD_DIR/third_party/unwind/unwind",
    ],
    AIB_COMPONENT="msi-util",
    AIB_ROLE="runtime",
)
